﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImagesList.aspx.cs" Inherits="Myproject.BSM.PcWeb.PcChannel.Slide.ImagesList" %>

<div class="bjui-pageHeader">
    <form runat="server" action="/bsm/PcWeb/PcChannel/slide/imagesList.aspx" id="pc_channel_imageslist_form" data-toggle="validate" data-alertmsg="false">
        <input id="pc_Channel_imglist_slideId" runat="server" name="pc_Channel_imglist_slideId" type="hidden" value="0" />
        <a class="btn btn-orange" href="javascript:;" data-toggle="reloadsearch" data-clear-query="true" data-icon="undo">刷新</a>
    </form>
</div>
<div class="bjui-pageContent">
    <div style="display: inline-block; vertical-align: middle;">
        <div id="doc_pic_up" data-toggle="upload" data-uploader="/BSM/Ashx/PcChannel/slideUpload.ashx"
            data-file-size-limit="1024000000"
            data-file-type-exts="*.jpg;*.png;"
            data-multi="true"
            data-on-upload-success="pc_channel_imageslist_js_success"
            data-icon="cloud-upload">
        </div>
        <input type="hidden" name="doc.pic" value="" id="doc_pic">
    </div>
    <table data-toggle="tablefixed" data-width="100%">
        <thead>
            <tr>
                <th style="text-align:center;"></th>
                <th style="text-align:center;">图片</th>
                <th style="text-align:center;">状态</th>
                <th style="text-align:center;">操作</th>
            </tr>
        </thead>

        <tbody>
            <%if (MessageTable != null && MessageTable.Rows.Count > 0)
              {
                  int i = 1;
                  foreach (System.Data.DataRow row in MessageTable.Rows)
                  {
                        
            %>
            <tr data-id="1">
                <td style="text-align:center;"><%= i %></td>
                <td style="text-align:center;">
                    <img width="100" height="60" src="<%= row["ImgUrl"] %>" /></td>
                <td style="text-align:center;">
                    <% if (bool.Parse(row["ImgShow"].ToString()))
                       { %>
                    <button onclick="javascript:pc_channel_imageslist_js_show('<%= row["ImgID"] %>',false)" type="button" class="btn btn-green" data-icon="eye">已显示</button>
                    <%}
                       else
                       {
                    %>
                    <button onclick="javascript:pc_channel_imageslist_js_show('<%= row["ImgID"] %>',true)" type="button" class="btn btn-red" data-icon="eye-slash">已隐藏</button>
                    <%
                       } %>
                </td>
                <td style="text-align:center;">
                    <a class="btn btn-red" href="javascript:pc_channel_imageslist_js_delete('<%= row["ImgID"] %>')">删除</a>
                </td>
            </tr>
            <%
                       i++;
                  }
              }%>
        </tbody>
    </table>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn-close" data-icon="close">关闭</button></li>
    </ul>
</div>
<script type="text/javascript">
    function pc_channel_imageslist_js_success(file, data) {
        //alert(file);
        //alert(data);
        var json = $.parseJSON(data)
        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $.ajax({
                type: "post",
                url: "/BSM/Ashx/PcChannel/imgAdd.ashx?Slideid=" + $("#pc_Channel_imglist_slideId").val() + "&url=" + json.fileName,
                dataType: "json",
                beforeSend: function (XMLHttpRequest) {

                },
                success: function (data) {
                    if (data.IsError) {
                        $(this).dialog('refresh', 'pc_channel_imglist');
                    }
                    else {
                        $(this).alertmsg('error', data.Message);
                    }
                },
                error: function () {
                    $(this).alertmsg('error', '新增失败，请稍后再试！');
                }
            });
        }
    }
    function pc_channel_imageslist_js_delete(id) {
        $(this).alertmsg('confirm', '确定要删除该图片吗?', {
            okCall: function () {
                $.ajax({
                    type: "post",
                    url: "/BSM/Ashx/PcChannel/imageDelete.ashx?id=" + id,
                    dataType: "json",
                    beforeSend: function (XMLHttpRequest) {

                    },
                    success: function (data) {
                        if (data.IsError) {
                            $(this).alertmsg('correct', data.Message);
                            $(this).dialog('refresh', 'pc_channel_imglist');
                        }
                        else {
                            $(this).alertmsg('error', data.Message);
                        }
                    },
                    error: function () {
                        $(this).alertmsg('error', '删除失败，请稍后再试！');
                    }
                });
            }
        });
    }
</script>
